package com.reebake.ideal.security.properties;

import cn.hutool.core.collection.CollectionUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.Set;

import static com.reebake.ideal.security.core.SecurityConstants.PROPERTY_PREFIX;

@Getter
@Setter
@ConfigurationProperties(prefix = PROPERTY_PREFIX)
public class ClientSecurityProperties implements InitializingBean {
	/** ignoring http urls */
	private Set<String> ignored = CollectionUtil.newHashSet();
	
	/** redirect url when authenticate failure */
	private String entryPointUrl;

    private Long accessTokenExpiredAhead = 30 * 60 * 1000L;

	@Override
	public void afterPropertiesSet() throws Exception {
		Set<String> defaultIgnored = CollectionUtil.newHashSet("/assets/**", "/webjars/**", "/favicon.ico", "/error", "/swagger-ui/**", "/doc.html", "/*/api-docs/**");
		this.ignored.addAll(defaultIgnored);
	}
}
